set P and set Q is as shown in the following illustration: After discovering that there are records that can join, the two records that P and Q point to will be join, depending on the algorithm. Then the output, then Q points to the next record, this time found that P and Q of the B-column value is not equal, according to the algorithm P will point to the next record, because this time P and Q point to the
Inner join, full outer join, left join, right jionCombination of inner join tablesFull outer is connected to the same combination of two tables. Table A has data that table B does not have (it is displayed as null), and
1. Prepare
Create a base table first:
CREATE TABLE mytb1 (ID serial,name character varying,age integer);To create an index on the name field:
Create INDEX Mytb1_name_index on MYTB1 (name);
To view the MYTB1 table structure:
postgres=# \d mytb1;
Tabl
Tags: strong internal connection target HTTP intermediate NAT condition ref dataOne, internal connection-inner jion: SELECT * FROM table1 INNER JOIN table2 on table1.field1 compopr table2.field2 The INNER JOIN operation can be divided into the following sections: Section description Table1, Table2 records the name of the table being combined. Field1, field2 the n
Tags: Right connection between select str notation GES data result connectionThe following lists the JOIN types that you can use, and the differences between them.
JOIN: Returns a row if there is at least one match in the table (Join=inner join)
Left
Label:SQL table join query (inner JOIN, full join, left JOIN, right join) Prerequisites: Suppose there are two tables, one is the student table and the other is the Student score
Label:SQL table join query (inner JOIN, full join, left JOIN, right join) Prerequisites: Suppose there are two tables, one is the student table and the other is the Student score
SQL table join query (inner join, full join, left join, right join)
Prerequisites: Assume that there are two tables, one is the student table and the other is the student renewal
Label:Prerequisites: Suppose there are two tables, one is the student table and the other is the Student score table. The table data are: One, internal connection-inner jion: The most common connection query may be that of identifying the student's name and score: Select S.name,m.mark from student S,mark m where S.id=m.studentid The above is our most common in
1 common table connections (inner join,left join,right join,full Join,cross join)if object_id(N'table1'N'U') is not NULL Drop Tabletable1if object_id(N'table2'N'U') is not NULL Drop Tabletable2Create TableTable1 (IDint, na
Inner join
There are two tables A and B.
The structure of Table A is as follows:
Aid: int; identifies the seed, primary key, and auto-increment ID
Aname: varchar
The data, that is, the records from select * From A, are shown in 1:
Figure 1: data in Table
Table B has the following structure:
Bid
Table A records the following:
Aid anum
1 a20050111
2 a20050112
3 a20050113
4 a20050114
5 a20050115
Table B records the following:
Bid bname
1 2006032401
2 2006032402
3 2006032403
4 2006032404
8 2006032408
The experiment is as follows:
1. Left join
The SQL statement is as follows:
Select * from
Left join B
On a. Aid
in the CREATESTMT structure, and then control whether or not to create a table or make an error message.Get the current user name as followsDatumcurrent_user (Pg_function_args) {pg_return_datum (DirectFunctionCall1 (Namein, Cstringgetdatum ( Getusernamefromid (GetUserId ()))));}This function is the intrinsic function of the PG, using the effect:postgres=# Select Current_User; Current_User--------------Postgres
with SQL commands
\? For help with Psql commands
\g or terminate with semicolon to execute query
\q to quit
Zwcdb=>
Create a table[Plain]View Plaincopyprint?
[Email protected] data]$ psql-u zhongwc-d zwcdb-h 192.168.1.203-p 1521
Password for user zhongwc:
Psql (9.2.2)
Type ' help ' for help.
Zwcdb=> CREATE TABLE T_ZHONGWC (PID integer,pname varchar (+), constraint ZHONGWC_PID_PK pri
Label: --View current Server database
SELECTDatname fromPg_database--view the created user table
SELECT * fromPg_stat_user_tables--Create a database
CREATE DATABASE"Fxsz_lt" withOWNER=Postgres ENCODING='UTF8'tablespace=Pg_default--lc_collate= ' Chinese (Simplified) _people ' s Republic of china.936 '
--lc_ctype= ' Chinese (Simplified) _people ' s Republic of china.936 'CONNECTION LIMIT=-1;
--Deleting a dat
SEQ Scan: Sequential scans, each read againIndex Scan: Indexed scan, read based on index conditions, suitable for less-hit queries, with sequential results
Hash: Find the hash value of the result set for subsequent hash links.Hash connection: According to the hash value, the conditional connection.Nest connections: Nested links, t1 tables correspond to rows without a T2 table, such as inner Join,cross
In the relational database management system, the relationship between data does not have to be determined when a table is created, and all information about an object is often stored in a table. When retrieving data, you can use the join operation to query information about different entities in multiple tables. Connection operations bring great flexibility to u
In the ViewSQLWhen we execute the plan, we find that there are many ways to connect tables, and this article introduces how tables are connected in order to better understand the execution plan and understand the principles of SQL execution.First, the connection method:Nested Loops (Nested Loops (NL))(hash) Hash connection (hash join (HJ))(merge) sort merge joins (sort merge Join (SMJ))Second, connection de
There are three methods to connect multiple tables:Nested loops,Hash joinAndSort merge join.The following describes three different connections:
I.Nested loop:
Nested loop join is a good choice for a small subset of connected data.. In a nested loop, the internal table is driven by the External table. Each row returned by the External
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.